home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 45
/
Freelog045.iso
/
Bas
/
Internet
/
Trellian
/
twp103.exe
/
{app}
/
Script
/
script,1.js
next >
Wrap
Text File
|
2003-02-08
|
13KB
|
514 lines
/*
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
*/
/*
** Windows API Style Functions
*/
function SetCapture(x)
{
x.document.onmouseup = x.onmouseup;
x.document.onmousedown = x.onmousedown;
}
function ReleaseCapture()
{
document.onmouseup=document.onmousedown=null
}
function MessageBox(s){confirm(s)}
/*
** Borland VCL Constants
*/
EmptyStr = ''
bsNone=""
bsSingle="outset"
bsRaised="outset"
bsLowered="inset"
clWhite="FFFFFF"
clBlack="000000"
clMenu="C0C0C0"
clMenuText="000000"
clBtnFace="C0C0C0"
clBtnShadow="808080"
clCaptionText="FFFFFF"
clActiveCaption="000090"
clWindow=clWhite
crDefault="default"
taLeftJustify="left"
taCenter="center"
taRightJustify="right"
function Point(x,y){this.x=x;this.y=y;return this}
function Rect(l,t,r,b){with(this){left=l;top=t;right=r;bottom=b;}return this}
function ShowMessage(s){alert(s)}
function UpperCase(s){return s.toUpperCase()}
function LowerCase(s){return s.toLowerCase()}
function IntToStr(s){return s.toString()}
function IntToHex(s){return s.toString(16)}
function StrToInt(s){return parseInt(s)}
function StrToDouble(s){return parseFloat(s)}
function Copy(s,i,c){return s.substring(i,i+c)}
function Length(s){return s.length}
function Random(a){return Math.floor(Math.random()*a+0.9999)}
function Pos(a,b){return b.indexOf(a)}
function Max(a,b){return a>b?a:b}
function Min(a,b){return a<b?a:b}
function HTTPEncode(s){return escape(s)}
function HTTPDecode(s){return unescape(s)}
function AnsiSameStr(A,B){return A==B}
function AnsiSameText(A,B){return A==B}
function ReturnFalse(){return false}
function ReturnTrue(){return true}
/*
** Name: TStringList
** Desc: Adds VCL style TStringList methods to the standard JavaScript
** string array.
*/
function TStringList(Self)
{
Self.IndexOf = function(Item)
{
for (var i = 0; i < Self.length; i++)
if (AnsiSameText(Self[i],Item)) return i;
return -1
}
Self.Values = function(Item, Def)
{
for (var i = 0; i < Self.length; i++)
{
var s = Self[i], j = s.indexOf('=')
if (AnsiSameText(s.substring(0, j), Item)) return s.substring(j + 1, s.length)
}
return Def
}
return Self
}
/*
** Name: CmdLine
** Desc: Returns the command line string that was sent to the page via the url
*/
function CmdLine()
{
var s=unescape(document.location.search)
return s.substring(s.indexOf('?')+1,s.length)
}
/*
** Name: ParamStrings
** Desc: Splits the command line string into a string list
*/
function ParamStrings()
{
return TStringList(CmdLine().split('%'))
}
/*
** Name: StringListValues
** Desc: Searchs a string list for ini style values
*/
function StringListValues(sl,name,def)
{
for (var i=0;i<sl.length;i++)
{
var s=sl[i]
var j=s.indexOf('=')
if (s.substring(0,j)==name) return s.substring(j+1,s.length)
}
return def
}
/*
** Name: TApplication
** Desc: The base class for the entire application. Only _one_ application
** should exist for each document.
*/
function TApplication(Self)
{
Self.SetTitle=function(x){Self.title=x}
document.onselectstart=ReturnFalse
document.ondragstart=ReturnFalse
window.onerror=function(desc,page,line,chr)
{
alert(
'JavaScript error occurred! \n'+
'The error was handled by '+
'a customized error handler.\n'+
'\nError description: \t'+desc+
'\nPage address: \t'+page+
'\nLine number: \t'+line
)
return true
}
return Self
}
function MenuCaption(s)
{
var r=""
for (var i=0;i<s.length;i++)r+=(s.charAt(i)=='&')?"<U>"+s.charAt(++i)+"</U>":s.charAt(i)
return r
}
function TComponent(Self,Owner)
{
Self.Owner=Owner
return Self
}
function TAbstractFont(Owner,Self)
{
TComponent(Self,Owner)
Self.SetName=function(x){Self.Owner.style.fontFamily=x}
Self.SetSize=function(x){Self.Owner.style.fontSize=x}
Self.SetColor=function(x){Self.Owner.style.color=x}
return Self
}
function TFont(Owner)
{
return TAbstractFont(Owner, new Object())
}
function TControl(Self,Owner)
{
TComponent(Self,Owner)
Self.Font = TFont(Self)
Self.OnClick=function(){}
Self.OnMouseUp=function(){}
Self.OnMouseDown=function(){}
Self.OnMouseMove=function(){}
Self.OnResize=function(){}
// Redirect the standard events to our new events.
Self.onclick=function(){Self.OnClick()}
Self.onresize=function(){Self.OnResize()}
Self.SetParent=function(x){(Self.Parent=x).appendChild(Self)}
Self.SetBorderWidth=function(x){Self.style.borderWidth=Self.BorderWidth=x}
Self.SetBorderStyle=function(x){Self.style.borderStyle=x}
Self.SetText=function(x){Self.innerHTML=x}
Self.GetText=function(){return Self.innerHTML}
Self.SetVisible=function(x){Self.style.visibility=x?"visible":"hidden"}
Self.SetEnabled=function(x){Self.disabled=!x}
Self.Show=function(){Self.SetVisible(true)}
Self.Hide=function(){Self.SetVisible(false)}
Self.SetOpacity=function(x){Self.style.filter="alpha(opacity="+(Self.Opacity=x)+")"}
Self.SetCursor=function(x){Self.style.cursor=Self.Cursor=x}
Self.GetLeft=function(){return Self.offsetLeft}
Self.GetTop=function(){return Self.offsetTop}
Self.GetWidth=function(){return Self.offsetWidth}
Self.GetHeight=function(){return Self.offsetHeight}
Self.SetBounds=function(x,y,w,h){with(Self.style){left=x;top=y;width=Max(w,0);height=Max(h,0)}}
Self.SetPos=function(x,y){with(Self){SetBounds(x,y,GetWidth(),GetHeight())}}
Self.SetSize=function(w,h){with(Self){SetBounds(GetLeft(),GetTop(),w,h)}}
Self.SetLeft=function(x){with(Self){SetBounds(x,GetTop(),GetWidth(),GetHeight())}}
Self.SetTop=function(x){with(Self){SetBounds(GetLeft(),x,GetWidth(),GetHeight())}}
Self.SetWidth=function(x){with(Self){SetBounds(GetLeft(),GetTop(),x,GetHeight())}}
Self.SetHeight=function(x){with(Self){SetBounds(GetLeft(),GetTop(),GetWidth(),x)}}
Self.SetRect=function(l,t,r,b){Self.SetBounds(l,t,r-l,b-t)}
Self.GetRight=function(){return Self.GetLeft()+Self.GetWidth()}
Self.GetBottom=function(){return Self.GetTop()+Self.GetHeight()}
Self.SetName=function(x){Self.name=Self.Name=x}
Self.SetColor=function(x){Self.style.backgroundColor=Self.Color=x}
Self.ControlCount=function(){return Self.children.length}
Self.Controls=function(x){return Self.children.item(x)}
Self.FullSize=function(){Self.style.left=Self.style.top="";Self.style.width=Self.style.height="100%"}
Self.AutoSize=function(){Self.style.width=Self.style.height=""}
Self.Font.SetName("MS Sans Serif");
Self.Font.SetSize(12);
// These seem to effect the standard XP style buttons
//Self.SetBorderWidth(2)
//Self.SetBorderStyle(bsNone)
return Self;
}
function TForm(Self,Owner)
{
Self=TControl(Self,Owner)
Self.Close=function(){Self.document.parentWindow.close()}
Self.GetWidth=function(){return document.all?Self.clientWidth:window.innerWidth}
Self.GetHeight=function(){return document.all?Self.clientHeight:window.innerHeight}
return Self
}
function TFormCreate(Owner,Options)
{
return TAbstractForm(window.open("","TForm", Options).document.body, Owner)
}
function TWinControl(Self,Owner)
{
TControl(Self,Owner)
Self.style.position="absolute"
Self.style.overflow="hidden"
Self.SetBounds(20,20,100,100)
return Self;
}
function TWinControlCreate(Owner,TagName,Attributes)
{
return TWinControl(document.createElement("<" + TagName + " " + Attributes + ">"),Owner)
}
function TButtonCreate(Owner)
{
return TWinControlCreate(Owner,"BUTTON");
}
function TMemoCreate(Owner)
{
return TWinControlCreate(Owner,"TEXTAREA");
}
function TMarqueeCreate(Owner)
{
return TWinControlCreate(Owner,"MARQUEE");
}
function TIFrameCreate(Owner)
{
return TWinControlCreate(Owner,"IFRAME");
}
function TTableCreate(Owner)
{
return TWinControlCreate(Owner,"TABLE");
}
function TEditCreate(Owner)
{
return TWinControlCreate(Owner,"INPUT");
}
function TLabeledControlCreate(Self)
{
Self.Label = TLabelCreate(Self);
Self.TLabeledControlSetParent = Self.SetParent;
Self.SetParent=function(a)
{
Self.TLabeledControlSetParent(a);
Self.Label.SetParent(a);
}
return Self;
}
function TLabeledEditCreate(Owner)
{
var Self = TLabeledControlCreate(TEditCreate(Owner));
Self._SetBounds = Self.SetBounds;
Self.SetBounds = function(x,y,w,h)
{
Self._SetBounds(x,y,w,h);
Self.Label.SetBounds(x-70,y,70,h);
}
return Self;
}
function TEditPasswordCreate(Owner)
{
var Self = TEditCreate(Owner);
Self.type = "password";
return Self;
}
function TEditFileCreate(Owner)
{
var Self = TEditCreate(Owner);
Self.type = "file";
return Self;
}
function TListItemCreate(Owner)
{
return TWinControlCreate(Owner,"OPTION");
}
function TCustomListBox(Self)
{
Self.AddItem=function(s){with(TListItemCreate(Self)){SetParent(Self);SetText(s);}}
Self.Count=function(){return Self.childNodes.length;}
Self.Clear=function(){while(Self.Count()>0) {Self.removeChild(Self.childNodes[0]);}}
return Self;
}
function TComboBoxCreate(Owner)
{
return TCustomListBox(TWinControlCreate(Owner,"SELECT"))
}
function TListBoxCreate(Owner)
{
return TCustomListBox(TWinControlCreate(Owner,"SELECT","multiple"))
}
function TLabelCreate(Owner)
{
var Self = TTableCreate(Owner)
Self.TableCell = Self.insertRow(0).insertCell(0)
Self.SetText=function(x){Self.TableCell.innerHTML=Self.Text=MenuCaption(x)}
Self.SetAlign=function(x){Self.TableCell.align=x}
return Self
}
function TCheckBoxCreate(Owner)
{
var Self = TEditCreate(Owner);
Self.type="checkbox";
Self.LabelControl = TLabelCreate(Owner);
Self.TCheckBoxSetBounds = Self.SetBounds;
Self.SetBounds = function(x,y,w,h)
{
Self.TCheckBoxSetBounds(x,y,h,h);
Self.LabelControl.SetBounds(x+h,y,w-h,h);
}
Self.TCheckBoxSetParent = Self.SetParent;
Self.SetParent=function(a)
{
Self.TCheckBoxSetParent(a);
Self.LabelControl.SetParent(a);
}
Self.SetText=function(s){Self.LabelControl.SetText(s);}
Self.GetText=function(){return Self.LabelControl.GetText();}
return Self;
}
function TRadioButtonCreate(Owner)
{
var Self = TEditCreate(Owner);
Self.type="radio";
Self.LabelControl = TLabelCreate(Owner);
Self.TCheckBoxSetBounds = Self.SetBounds;
Self.SetBounds = function(x,y,w,h)
{
Self.TCheckBoxSetBounds(x,y,h,h);
Self.LabelControl.SetBounds(x+h,y,w-h,h);
}
Self.TCheckBoxSetParent = Self.SetParent;
Self.SetParent=function(a)
{
Self.TCheckBoxSetParent(a);
Self.LabelControl.SetParent(a);
}
Self.SetText=function(s){Self.LabelControl.SetText(s);}
Self.GetText=function(){return Self.LabelControl.GetText();}
return Self;
}
function TPictureCreate(Owner)
{
var Self = TWinControlCreate(Owner,"IMG")
Self.SetText=function(){}
Self.LoadFromFile=function(x){Self.src=Self.Image=x}
return Self
}
function TImageCreate(Owner)
{
var Self = TPanel(Owner)
Self.SetBorderWidth(0)
Self.Picture=TPictureCreate(Owner)
Self.Picture.FullSize()
Self.Picture.SetParent(Self)
return Self;
}
function TPanelCreate(Owner)
{
var Self = TWinControlCreate(Owner,"SPAN")
Self.SetColor(clBtnFace)
Self.SetBorderWidth(1)
Self.SetBorderStyle(bsRaised)
Self.SetCursor(crDefault)
return Self
}
function TWebBrowserCreate(Owner)
{
return TWinControlCreate(Owner,"IFRAME")
}
function TSpeedButtonCreate(Owner)
{
var Self = TLabelCreate(Owner)
Self.onmouseenter = function()
{
Self.MouseInside=1
Self.SetBorderStyle(Self.MouseDown?bsLowered:bsRaised);
}
Self.onmouseleave = function()
{
Self.MouseInside=0
Self.SetBorderStyle(bsNone);
}
Self.onmouseup=function()
{
Self.MouseDown=0
Self.SetBorderStyle(Self.MouseInside?bsRaised:bsNone)
ReleaseCapture();
}
Self.onmousedown=function()
{
SetCapture(Self);
Self.SetBorderStyle(bsLowered)
Self.MouseDown=1
}
Self.SetBorderStyle(bsNone)
Self.SetBorderWidth(1)
Self.SetAlign(taCenter)
return Self
}
Application = TApplication(document)
MainForm = TForm(Application.body, Application);